<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <!-- 不绑定函数，直接在 行内修改数据 强烈不建议 -->
    <button v-on:click="msg='值改变了'">按钮</button>
    
    <hr>
    <!-- 绑定函数 -->
    <!-- 1 不加括号 -->
    <button @click="changeMsg">按钮</button>
    <hr>
    <!-- 2 加括号 作用：事件触发时传递参数 -->
    <button @click="changeMsg2('这是我传入的值')">按钮</button>

    <hr>
    {{msg}}
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const msg = '这是全局变量';
    const { createApp } = Vue;
    const app = createApp({
      data(){
        return {
          msg: '你好vue'
        }
      },
      methods: {
        changeMsg() {
          this.msg = '值改变了'
        },
        changeMsg2(msg){
          this.msg = msg;
        }
      },
    })
    app.mount('#app')
  </script>
</body>
</html>